package com.ssm.gbq.service.impl;

import com.ssm.gbq.dao.FlowersDao;
import com.ssm.gbq.model.Flowers;
import com.ssm.gbq.service.FlowersService;
import gbq.ssm.utils.BusinessException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FlowersServiceImpl implements FlowersService{

    @Autowired
    private FlowersDao flowersDao;

    public List<Flowers> showFlowersTable() {
        return flowersDao.showFlowersTable();
    }

    public List<Flowers> showFlowersByPage(Flowers flowers, int currentPage, int pageSize) throws Exception {
        return flowersDao.showFlowersByPage(flowers, currentPage, pageSize);
    }

    public Flowers getFlowersById(Integer id)throws BusinessException {
        try {
            return flowersDao.getFlowersById(id);
        } catch (Exception e) {
            throw new BusinessException("通过id查询失败！",e.getMessage());
        }
    }

    public int updateFlower(Flowers flowers) throws Exception {
        return flowersDao.updateFlower(flowers);
    }

    public int addFlower(Flowers flowers) throws Exception {
        return flowersDao.addFlower(flowers);
    }

    public int delFlower(Integer id) throws Exception {
        return flowersDao.delFlower(id);
    }

    public int getFlowersCount(Flowers flowers) {
        return flowersDao.getFlowersCount(flowers);
    }

    public int deleteFlowers(List<Integer> ids) {
        return flowersDao.deleteFlowers(ids);
    }
}
